<?php
include('../../include/functions.inc.php');
include('../../include/inputbuilder.inc.php');
include('../../include/maintenance.inc.php');
if (isEmpty(getParam('ID'))) {
    echo 'WRONG PARAMETER';
} else {
    $mTeacher = unserialize($_SESSION['mTeacher']);

    $builder = new InputBuilder();
    $builder->db = $db;
    $tabs = $db->query_select('cllg_table_tab', "TABLE_NAME='cllg_teacher'");
    $rows = $db->query_select('cllg_teacher', sprintf("ID='%s'", getParam('ID')));
    foreach ($rows as $row) {
        ?>
        <form id="<?php echo $mTeacher->formName; ?>" name="<?php echo $mTeacher->formName; ?>" method="POST" action="<?php echo $mTeacher->updateUrlPage; ?>">
            <div id="panel" class="">
                <ul class="nav nav-tabs">
                    <?php
                    $ix = 0;
                    foreach ($tabs as $t) {
                        $ix++;
                        ?>
                        <li class="active" style="font-weight:bolder" tabindex="<?php echo $ix; ?>"><a><?php echo $t["CAPTION"]; ?></a></li>
                    <?php } ?>
                </ul>
                <div class="">
                    <?php
                    $ix = 0;
                    foreach ($tabs as $t) {
                        $ix = $t["ID"];
                        ?>
                        <div id="<?php echo $ix; ?>" class="">

                            <table class=""  width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <th scope="col" style="text-align:left"><legend>DATOS CATEDRATICO</legend></th>
                                    <th scope="col" style="padding-top:"><legend><div style="margin-left: 30%;margin-top: 1.4%" class="btn-group">
                                        <input type="button" name="cmdOk" class="btn btn-info"  id="cmdOk" value="Guardar" onClick="javascript:formOkBt($(this.form),updateAction);jQuery('#cmAddcontainer').show();" />
                                        <input type="button" name="eliminar" id="eliminar" onclick="javascript:deleteAction('<?php echo $mTeacher->deleteUrlPage; ?>',<?php echo $mTeacher->getDeleteUrl(); ?>); jQuery('#cmAddcontainer').show();" value="Eliminar" class="btn btn-info" />        
                                        <input type="button" name="cmdCancel" id="cmdCancel" value="Cancelar" class="btn btn-info" onClick="loadTable();jQuery('#cmAddcontainer').show();" /></div></legend></th>
                                </tr>
                                <tr>
                                    <td colspan="2"><br/><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <?php
                                            if ($ix == 5) {
                                                //solo filas
                                                ?>  
                                                <tr>
                                                    <td width="25%">*IDENTIFICACIÓN</td>
                                                    <td width="75%">            <input name="ID" type="text" value="<?php echo getParam('ID'); ?>" id="ID" />          </td>
                                                </tr>


                                                <tr>
                                                    <td>*NOMBRES</td>
                                                    <td>
                                                        <input name="FIRST_NAME" type="text" id="FIRST_NAME" value="<?php echo $row['FIRST_NAME']; ?>" size="50" maxlength="100" />
                                                        <label></label></td>
                                                </tr>
                                                <tr>
                                                    <td>*APELLIDOS</td>
                                                    <td>
                                                        <input name="LAST_NAME"  type="text" id="LAST_NAME" value="<?php echo $row['LAST_NAME']; ?>" size="50" maxlength="100" />            </td>
                                                </tr>
                                                <tr>
                                                    <td>SEXO</td>
                                                    <td>            <select name="GENDER" size="1" id="GENDER">
                                                            <option value="M" <?php
                                if (!(strcmp("M", $row['GENDER']))) {
                                    echo "selected=\"selected\"";
                                }
                                ?>>Masculino</option>
                                                            <option value="F" <?php
                                if (!(strcmp("F", $row['GENDER']))) {
                                    echo "selected=\"selected\"";
                                }
                                ?>>Femenino</option>
                                                        </select>          </td>
                                                </tr>
                                                <tr>
                                                    <td>FECHA DE NACIMIENTO</td>
                                                    <td>          

                                                        <input name="BIRTH_DATE" type="text" id="BIRTH_DATE" value="<?php echo $row['BIRTHDATE']; ?>" />
                                                        <input name="STATUS" type="hidden" id="STATUS" value="<?php echo $row['STATUS']; ?>" /></td>
                                                </tr>
                                                <tr>
                                                    <td>EDAD</td>
                                                    <td>
                                                        <h3><div id="edad">
                <?php $cYear = date('Y'); ?>
                                                <?= $cYear - date('Y', strtotime($row['BIRTHDATE'])) ?>

                                                                &nbsp;A&ntilde;os</div></h3>
                                                    </td>
                                                </tr>
                <?php
            }
            $builder->build("cllg_teacher", getParam('ID'), $t['ID']);
            ?> 
                                        </table></td>
                                </tr>
                                <tr>
                                    <td colspan="2"> </td>
                                </tr>
                            </table>
                        </div>
        <?php } ?> 

                </div>
            </div>
        </form>
        <?php
    }
    $_SESSION['fields'] = serialize($builder->fieldsArray);
}?>